package com.itheima.admin.controller;

import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicParameters;
import com.itheima.admin.service.AdUserService;
import com.itheima.common.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @program: itheima-leadnews
 * @description: 登录功能
 * @author: pw
 * @create: 2022-08-10 17:24
 **/
@RestController
@RequestMapping("/login")
@Api(tags = "系统登录")
public class LoginController {

    //登录功能
    @Autowired
    private AdUserService adUserService;

    @PostMapping("/in")
    @ApiOperation(value = "用户登录校验")
    @DynamicParameters(name = "JSON", properties = {
            @DynamicParameter(name = "name", value = "登录用户名", required = true),
            @DynamicParameter(name = "password", value = "密码", required = true)
    })

    public ResultVo in(@RequestBody HashMap<String, String> map) {
//            登录校验
        HashMap<String, Object> data = adUserService.loginCheck(map);
        return ResultVo.ok(data);
    }


}
